<template>
  <div class="command__wrapper_container" v-show="visible">
    <el-container>
      <el-header :height="'45'">
        <svg-icon icon-class="table"></svg-icon>
        群众举报
        <span class="el-icon-circle-close" @click="handleCloseDialog"></span>
      </el-header>
      <el-main>
        <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
          <el-form-item prop="content" label="报警内容" style="width: 67%">
            <el-input
              v-model="queryParams.content"
              style="width: 300px"
              placeholder="请输入查询内容"
              clearable
              size="small"
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
          <el-form-item style="width: 29%">
            <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
            <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
          </el-form-item>
        </el-form>
        <el-table v-loading="loading" :data="fenceAlarmList">
          <el-table-column type="selection" width="55" align="center"/>
          <el-table-column label="主建id" align="center" prop="id" v-if="false"/>
          <el-table-column label="定位" align="center" class-name="small-padding fixed-width">
            <template slot-scope="scope">
              <el-button
                size="mini"
                type="text"
                @click="showPoint(scope.row)"
              >定位
              </el-button>
            </template>
          </el-table-column>
          <el-table-column label="案件号" align="center" class-name="small-padding fixed-width"  width="150">
            <template slot-scope="scope">
              <el-button
                size="mini"
                type="text"
                @click="showEvt(scope.row)"
              >{{ scope.row.evtCode }}
              </el-button>
            </template>
          </el-table-column>
          <el-table-column label="违法、违规信息" align="center" prop="violationName" width="180"/>
          <el-table-column label="案件地点" align="center" prop="evtAddress" show-overflow-tooltip/>
<!--          <el-table-column label="举报时间" align="center" prop="reporterTime" width="180">-->
<!--          </el-table-column>-->
          <el-table-column label="案件内容" align="center" show-overflow-tooltip>
            <template slot-scope="scope">
              <span v-html="scope.row.evtContent">{{scope.row.evtContent}}</span>
            </template>
          </el-table-column>
          <el-table-column label="信息核实" align="center" class-name="small-padding fixed-width">
            <template slot-scope="scope">
              <el-row v-if="scope.row.isverify === '1'">
                {{'已核实'}}
              </el-row>
              <el-row v-else v-else-if="scope.row.evtState === '4'">
                {{'已作废'}}
              </el-row>
              <el-row v-else>
                {{'待核实'}}
              </el-row>
            </template>
          </el-table-column>
        </el-table>
        <pagination
          v-show="total>0"
          :total="total"
          small
          layout="total,prev, pager, next"
          :page.sync="queryParams.pageNum"
          :limit.sync="queryParams.pageSize"
          @pagination="getList"
        />
      </el-main>
    </el-container>
  </div>
</template>
<script>
  import {
    queryAuditListForMap
  } from '@/api/frontierEvent/event'

  export default {
    name: 'faultAlarm',
    components: {},
    props: {
      visible: {
        type: Boolean,
        default: false
      }
    },
    data() {
      return {
        // 遮罩层
        loading: false,
        // 显示搜索条件
        showSearch: true,
        // 总条数
        total: 0,
        // 巡护任务表格数据
        fenceAlarmList: [],
        // 案件类型字典
        evtTypeOptions: [],
        // 案件来源字典
        evtSourceOptions: [],
        // 案件状态字典
        evtStateOptions: [],
        // 违法、违规信息字典
        violationOptions: [],
        // 管辖区字典
        areaNameOptions: [],
        // 查询参数
        queryParams: {
          pageNum: 1,
          pageSize: 10,
          evtType: undefined,
          evtSource: '1',
          violation: undefined,
          areaName: undefined,
          reporterTime: undefined,
          orderByColumn: 'reporterTime',
          isAsc: 'desc'
        }
      }
    },
    created() {
      this.getList()
      this.getDicts('evt_type').then(response => {
        this.evtTypeOptions = response.data
      })
      this.getDicts('evt_source').then(response => {
        this.evtSourceOptions = response.data
      })
      this.getDicts('evt_state').then(response => {
        this.evtStateOptions = response.data
      })
      this.getDicts('evt_violation_type').then(response => {
        this.violationOptions = response.data
      })
      this.getDicts('evt_area').then(response => {
        this.areaNameOptions = response.data
      })
    },
    methods: {
      handleOpenDialog() {
        this.getList()
      },
      handleCloseDialog() {
        this.$emit('close')
      },
      /** 查询巡护任务列表 */
      getList() {
        this.loading = false
        queryAuditListForMap(this.queryParams).then(response => {
          this.fenceAlarmList = response.rows
          this.total = response.total
          this.showAlarmNum(this.total)
          this.loading = false
        })
      },
      // 案件类型字典翻译
      evtTypeFormat(row, column) {
        return this.selectDictLabel(this.evtTypeOptions, row.evtType)
      },
      // 案件来源字典翻译
      evtSourceFormat(row, column) {
        return this.selectDictLabel(this.evtSourceOptions, row.evtSource)
      },
      // 案件状态字典翻译
      evtStateFormat(row, column) {
        return this.selectDictLabel(this.evtStateOptions, row.evtState)
      },
      // 违法、违规信息字典翻译
      violationFormat(row, column) {
        return this.selectDictLabel(this.violationOptions, row.violation)
      },
      // 管辖区字典翻译
      areaNameFormat(row, column) {
        return this.selectDictLabel(this.areaNameOptions, row.areaName)
      },
      /** 搜索按钮操作 */
      handleQuery() {
        this.queryParams.pageNum = 1
        this.getList()
      },
      /** 重置按钮操作 */
      resetQuery() {
        this.resetForm('queryForm')
        this.handleQuery()
      },
      showAlarmNum(e) {
        this.$emit('showAlarmNum', e)
      },
      showPoint(row) {
        this.$emit('showPoint', row)
      },
      showEvt(e) {
        const detail = {}
        detail.target = 'app'
        detail.item = e
        this.$emit('ShowDetail', detail)
      }
    }
  }
</script>
<style scoped lang="scss">
  @import '../style/main';

  .el-form-item {
    margin-bottom: 10px;
  }
</style>
